<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>产品列表页面-分页</title>
<link href="<?php echo $this->_webroot('/style/jq-ui/jquery-ui-1.8.18.custom.css'); ?>" rel="stylesheet" type="text/css">
<link href="<?php echo $this->_webroot('/style/css.css'); ?>" rel="stylesheet" type="text/css">
<link href="<?php echo $this->_webroot('/style/content.css'); ?>" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<?php echo $this->_webroot('script/jquery-1.7.1.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo $this->_webroot('script/jquery-ui-1.8.18.custom.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo $this->_webroot('script/jquery.carouFredSel-5.5.0-packed.js'); ?>"></script>
<script type="text/javascript" src="<?php echo $this->_webroot('script/js.js'); ?>"></script>
<script type="text/javascript" src="<?php echo $this->_webroot('script/content.js'); ?>"></script>
</head>

<body>
<psp:tags     htmlname='default_topnav'  iconname='defaulttopnav' />

<div class="head headpadding">
	<div class="logo-box">
    	<a class="logo" href="#"><img src="<?php echo $this->_webroot('images/logo1.gif'); ?>" alt="" /></a>
    </div>  
	
    <psp:tags     htmlname='city'  iconname='city' />
    
    <div class="search-box">
        <div class="search_form_wrap">
        	<div class="searchForm1">
            	<form action="<?php echo $this->_url('default/productlist/');?>" method="get" id="searchkeyForm" class="searchkeyForm" name="searchkeyForm" >
            	<input type="text" class="searchInput1" name="k"  />
                <input type="submit" class="searchBtn1 search_alertimg" value="搜产品"  />
                </form>			
            </div>
            <div class="adsearch1">
            	<a href="<?php echo $this->_url('default/productlist/');?>">高级搜索</a><br />
                <a href="<?php echo $this->_url('article/index/?id=3');?>">使用帮助</a>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <div class="clear"></div>
</div>
<psp:tags     htmlname='default_navlist'  iconname='default_navlist' />

<div class="container margintop1">

	<!-- main_left -->
	<div id="main_left">
    	<div class="leftMenuBox leftMenuBoxwidth">
        	<ul class="leftMenu leftMenuBoxwidth">
		    <?php 
			$this->controller->loadModel('brandgoodscategories');
			$this->controller->loadModel('brand');			
			?>
            <?php $i=0;  foreach(array_slice ($CATEGORY[0], 0) as $key=>$cat){ $i++; ?>			
                <li class="<?php if ($i==1) { ?>first <?php } ?>leftMenuLi">
                    <div class="item arrow1">
                        <a href="#" class="leftMenuItem a_width">
                            <div class="leftMenuLeft"><?php echo  $cat['cat_name'];?></div>
                        </a>
                        <b class="pointer"></b>
                    </div>
			        <?php $count1 = 0;  if(isset($CATEGORY[$cat['id']]) && $CATEGORY[$cat['id']]){?>
				        <?php  foreach(array_slice ($CATEGORY[$cat['id']], 0) as $subcat){  $count1 ++ ;  ?> 					
					    <?php }?>
				    <?php }?> 
                    <?php  $count2 = round($count1 / 2 );?>						
                    <div class="leftMenuCat left1">
                    	<div class="catLeft">
			            <?php if(isset($CATEGORY[$cat['id']]) && $CATEGORY[$cat['id']]){?>
				            <?php $count3=0; foreach(array_slice ($CATEGORY[$cat['id']], 0) as $subcat){  $count3++;  if($count3>$count2)break; ?> 						
                        	<div class="catItem">
                            	<h3><a href="<?php echo $this->_url('default/productlist1/');?>?id=<?php echo  $subcat['id'];?>&k=<?php echo  $k;?>&suppid=<?php echo  $suppid;?>" title="<?php echo  $subcat['cat_name'];?>"><?php echo  $subcat['cat_name'];?></a></h3>
			                    <?php if(isset($CATEGORY[$subcat['id']]) && $CATEGORY[$subcat['id']]){?>
				                    <?php  foreach(array_slice ($CATEGORY[$subcat['id']], 0) as $subcat1){?> 
				                        <a href="<?php echo $this->_url('default/productlist1/');?>?id=<?php echo  $subcat1['id'];?>&k=<?php echo  $k;?>&suppid=<?php echo  $suppid;?>" title="<?php echo  $subcat1['cat_name'];?>" style="color:#000;"><?php echo  $subcat1['cat_name'];?>:</a> 
			                            <?php if(isset($CATEGORY[$subcat1['id']]) && $CATEGORY[$subcat1['id']]){?>
				                            <?php  foreach(array_slice ($CATEGORY[$subcat1['id']], 0) as $subcat2){?> 					                
									        <a href="<?php echo $this->_url('default/productlist1/');?>?id=<?php echo  $subcat2['id'];?>&k=<?php echo  $k;?>&suppid=<?php echo  $suppid;?>" title="<?php echo  $subcat2['cat_name'];?>"><?php echo  $subcat2['cat_name'];?></a>
										    <?php }?>
				                        <?php }?>	
                                        <br/>										
									<?php }?>
				                <?php }?> 
                            </div>
					        <?php }?>
				        <?php }?> 
                        </div>
                        <div class="catRight">
			            <?php if(isset($CATEGORY[$cat['id']]) && $CATEGORY[$cat['id']]){?>
				            <?php $count3=0; foreach(array_slice ($CATEGORY[$cat['id']], 0) as $subcat){ $count3++;  if($count3<=($count2))continue;  ?> 						
                        	<div class="catItem">
                            	<h3><a href="<?php echo $this->_url('default/productlist1/');?>?id=<?php echo  $subcat['id'];?>&k=<?php echo  $k;?>&suppid=<?php echo  $suppid;?>" title="<?php echo  $subcat['cat_name'];?>"><?php echo  $subcat['cat_name'];?></a></h3>
			                    <?php if(isset($CATEGORY[$subcat['id']]) && $CATEGORY[$subcat['id']]){?>
				                    <?php  foreach(array_slice ($CATEGORY[$subcat['id']], 0) as $subcat1){?> 
				                        <a href="<?php echo $this->_url('default/productlist1/');?>?id=<?php echo  $subcat1['id'];?>&k=<?php echo  $k;?>&suppid=<?php echo  $suppid;?>" title="<?php echo  $subcat1['cat_name'];?>" style="color:#000;"><?php echo  $subcat1['cat_name'];?>:</a> 
			                            <?php if(isset($CATEGORY[$subcat1['id']]) && $CATEGORY[$subcat1['id']]){?>
				                            <?php  foreach(array_slice ($CATEGORY[$subcat1['id']], 0) as $subcat2){?> 					                
									        <a href="<?php echo $this->_url('default/productlist1/');?>?id=<?php echo  $subcat2['id'];?>&k=<?php echo  $k;?>&suppid=<?php echo  $suppid;?>" title="<?php echo  $subcat2['cat_name'];?>"><?php echo  $subcat2['cat_name'];?></a>
										    <?php }?>
				                        <?php }?>
                                        <br/>										
									<?php }?>
				                <?php }?> 
                            </div>
					        <?php }?>
				        <?php }?> 	
                        </div>
					
                    </div>
                </li>
            <?php }?>				

                <li class="last"><a href="<?php echo $this->_url('default/productlist/');?>" class="more">更多商品>></a></li>
            </ul>
            <div class="clear"></div>
        </div>              
        
        <!-- 销量排行 -->
        <psp:tags     htmlname='productlist_ranksales'  iconname='productlist_ranksales' />
        <!-- 销量排行 -->
        
        <!--  热销商品 -->
        <psp:tags     htmlname='productlist_hotgoods'  iconname='productlist_hotgoods' />
        <!--  热销商品 end -->
        
        
        <div class="clear"></div>
        
        
    </div>
    <!-- main_left end -->

	<!-- main_right -->
	<div id="main_right">
<?php
$all_url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
if(!strstr($all_url,"?")) {
$all_url = $all_url."?";
}
$all_url = preg_replace("/&down_price=([^&]+)/","",$all_url);
$all_url = preg_replace("/&up_price=([^&]+)/","",$all_url);
$all_url = preg_replace("/&pv=([^&]+)/","",$all_url);
$all_url = preg_replace("/&fpv=([^&]+)/","",$all_url);
$all_url = preg_replace("/&new=([^&]+)/","",$all_url);
?>
    	<!-- 所有商品 -->
		<div class="allgoods_wrap">
            <div class="all_goods_hd">
                <ul class="all_goods_hd_ul">
                	<li><a href="<?php echo $this->_url('default/productlist/?');?>" class="popularity allgoods">所有商品</a></li>
                    <li><a href="<?php echo $all_url.'&pv=1';?>" class="popularity">人气</a></li>
                    <li><a href="<?php echo $all_url.'&fpv=1';?>" class="popularity">收藏</a></li>
                    <li><a href="<?php echo $all_url.'&new=1';?>" class="popularity">新品</a></li>
                </ul>
            </div>
            <div class="all_godds_body">
            	<div class="search_conditon">
                	<img src="<?php echo $this->_webroot('images/condition_left.jpg'); ?>" width="5" height="33" class="condition_left" />
                    <div class="search_condition_center">
                    <form action="<?php echo $this->_url('default/productlist/');?>" method="get" >
<script language="JavaScript" src="<?php echo $this->_webroot('servtools/ajax_client/ajax.js');?>"></script>
<script language="JavaScript">
<!--
function areachanged(value,type){
	if(value > 0) {	
		ajax("<?php echo $this->_url('default/getareas');?>","POST","value="+value+"&mode=shopinfo&pre=shop_&type="+type,function(return_text){
			var return_text = return_text.replace(/[\n\r]/g,"");
			if(return_text==""){
				alert("请重新选择!！");
			} else {
				if(type==0) {
					document.getElementById("user_province").innerHTML = return_text;
					show("user_province");
					hide("user_city");
				} else if(type==1) {
					document.getElementById("user_city").innerHTML = return_text;
					show("user_city");
				}
			}
		});
	} else {
		if(type==1) {
			hide("user_city");
		} else if(type==0) {
			hide("user_city");
			hide("user_province");
		}
	}
}
function hide(id) {
	document.getElementById(id).style.display = 'none';
}
function show(id) {
	document.getElementById(id).style.display = '';
}
//-->
</script>	
<?php 
        $this->controller->loadModel('area');		
		$return_array = $this->controller->area->find('all');
	    $areas_info = array();		
	    foreach($return_array as $k=>$v) {
		    $areas_info[$v['area']['area_type']][$v['area']['id']]['id'] = $v['area']['id'];
		    $areas_info[$v['area']['area_type']][$v['area']['id']]['parent_id'] = $v['area']['parent_id'];
		    $areas_info[$v['area']['area_type']][$v['area']['id']]['area_name'] = $v['area']['area_name'];
		    $areas_info[$v['area']['area_type']][$v['area']['id']]['area_type'] = $v['area']['area_type'];
	    }
?>					
                    	<span>地区：</span>
								
								<span id="user_province">
								<select name="province" onchange="areachanged(this.value,1);">
									<option value='0'>选择省份</option>
								<?php foreach($areas_info[1] as $v) { ?>
									<option value="<?php echo  $v['id'];?>" <?php   if($v['id']==$province){echo 'selected';}?>><?php echo  $v['area_name'];?></option>
								<?php }?>
								</select>
								</span>
								
								<span id="user_city">
								<?php 	 if($province){?>
								<select name="city" onchange="areachanged(this.value,2);">
									<option value='0'>选择城市</option>
								    <?php foreach($areas_info[2] as $v) {
										if($v['parent_id'] == $province){?>
									<option value="<?php echo  $v['id'];?>" <?php  if($v['id']==$city){echo 'selected';}?>><?php echo  $v['area_name'];?></option>
								<?php 	}
								}?></select>
								<?php }?>
								</span>

                        <span class="price_label">价格：</span>
                        <input type="text" class="inputtext1" name="min_price" value="<?php echo $min_price;?>" />-<input type="text" class="inputtext1"  name="max_price"  value="<?php echo $max_price;?>" />
                        <a href="<?php echo $all_url.'&down_price=1';?>" class="down_arrow"></a>
                    	<a href="<?php echo $all_url.'&up_price=1';?>" class="up_arrow"></a>
						 <input type="hidden"  name="suppid" value="<?php echo $suppid; ?>"/>
                        <input type="submit" value="" class="submit2 marginleft1" />
						</form>
                    </div>                    
                    <img src="<?php echo $this->_webroot('images/condition_right.gif'); ?>" width="5" height="33" class="condition_right" />
                	<div class="clear"></div>
                </div>
				
                <ul class="books_wrap">
                	<li class="books_wrap_li">
                    	<ul class="pro_list_padding pro_list_padding1">

    
					<?php foreach($result['data'] as $k=>$v){?>						
                            <li>
                                <div class="prot_img">
                                    <span class="newprot">新品上市</span>
                                    <a target="_blank" href="<?php echo $this->_url('shop/productshow/'.$v['goods_id']);?>"><img  src="<?php echo  $v['is_set_image'] ? $v['goods_thumb'] : $this->_webroot('/user/images/nopic.gif');?>"  width="160px" height="121px"  alt="<?php echo $v['goods_name'];?>" onerror="this.src='<?php echo $this->_webroot('/user/images/nopic.gif'); ?>'"/></a>
                                </div>
                                <div class="title" style="overflow: hidden;"><a href="<?php echo $this->_url('shop/productshow/'.$v['goods_id']);?>" ><?php echo  str_replace($ks,$redks,$v['goods_name']);?></a></div>
                                <div class="attribute"><span>零售价：</span><span>￥<?php echo  $v['goods_refer_price'];?></span></div>
                                <div class="attribute"><span>爱搜价：</span><span class="colorred"><?php if (isset($this->controller->my->id)) { ?>￥<?php echo  $v['goods_price'];?><?php }else{ ?>会员可见<?php } ?></span></div>
                                <!--<div class="attribute vip"><span><img src="<?php echo $this->_webroot('images/vip1.jpg'); ?>" />：</span><span class="vipPrice1">￥40.00</span></div>-->
                                <div class="attribute"><span>库存：</span><span><?php echo $v['goods_number'] ;?>件</span></div>
                                <div class="attribute attribute1">
                                    <span>数量：</span><a class="cutOrder" href="#"><img src="<?php echo $this->_webroot('images/cutNum.jpg'); ?>" /></a><input type="text" class="orderNum" id="num<?php echo $v['goods_id'] ;?>" name="num<?php echo $v['goods_id'] ;?>"  value="1" /><a class="addOrder" href="#"><img src="<?php echo $this->_webroot('images/addNum.jpg'); ?>" /></a>
                                </div>
			                    <input type="hidden" value="<?php echo  $v['shop_id'];?>" id="shop_id<?php echo $v['goods_id'] ;?>" name="shop_id<?php echo $v['goods_id'] ;?>" />									
                                <input type="button" class="orderBtn" value=""  onclick="javascript:addCart(<?php echo $v['goods_id'] ;?>);" />
                            </li>
					<?php }?>							


                            <div class="clear"></div>  
             			</ul>
						
						<form  method="get" action="<?php echo $this->_url('default/productlist/');?>">
                        <div class="page-box margintop6">
                            <a href="<?php echo $result['page']['prevPage'];?>" class="pre">上一页</a>
                            <span class="on"><?php echo $result['page']['current']['num'];?></span>	
                            <?php foreach($result['page']['plist'] as $k => $v ) { ?>							
                            <a href="<?php echo $v; ?>"><?php echo $k; ?></a>
							<?php } ?>
                            <a href="<?php echo $result['page']['nextPage'];?>" class="next">下一页</a>
                            <span>共<?php echo $result['page']['pageCount'];?>页</span>
							
                            <span>到<input type="text" class="go-page" name="page" />页</span>
							<input type="hidden"  name="cat_id" value="<?php echo $cat_id; ?>"/>
						    <input type="hidden"  name="k" value="<?php echo $keyworld; ?>"/>
						    <input type="hidden"  name="min_price" value="<?php echo $min_price; ?>"/>
						    <input type="hidden"  name="max_price" value="<?php echo $max_price; ?>"/>
						    <input type="hidden"  name="province" value="<?php echo $province; ?>"/>
						    <input type="hidden"  name="city" value="<?php echo $city; ?>"/>
							<input type="submit" class="go-page-btn" value="跳&nbsp;转" />							
                         </div>
						 </form>
						 
                    </li>
                </ul>
            <input type="hidden" value="<?php echo  $this->controller->my->id;?>" id="shop_user" />			
<script language="JavaScript" src="<?php echo $this->_webroot('servtools/ajax_client/ajax.js');?>"></script>
<script language="JavaScript">
	<!--
		function addCart(id) {
			var num = document.getElementById('num'+id);
			var shop_id = document.getElementById('shop_id'+id).value;
			var user_id = document.getElementById('shop_user').value;
			
			var num_reg = /^(\d+)$/;
			if(!num_reg.test(num.value)){
				alert('购买数量格式不正确!');
				return;
			}
			if(num.value=='0'){
				alert('购买数量不能为0！');
				return;
			}

			if (shop_id == user_id){
				alert('自己的商品不能放入购物车');
			}else{
				ajax("<?php echo $this->_url('shop/goodsaddcart');?>","POST","id="+id+"&num="+num.value,function(data){
					if(data == 1) {
						alert("已成功添加到您的购物车！");
					} else if(data == -1) {
						alert("此商品已在您的购物车里！");
					} else if(data == -2) {
						alert("库存里没有这么多商品！");
					} else {
						alert("添加失败，请确认您是否已登陆！");
					}
				});
			}
		}
	-->	
</script>					
                <div class="clear"></div>
            </div>
        	                    
    	</div>
		<!-- 所有商品 end -->
    </div>
    <!-- main_right end -->

	<div class="clear"></div>
</div>

<!-- 友情链接 -->
<psp:tags     htmlname='links'  iconname='links' />
<!-- 友情链接 end -->

<div class="clear"></div>

<psp:tags     htmlname='default_footer'  iconname='defaultfooter' />
</body>
</html>